package com.bwie.controller;

import com.bwie.pojo.TbGroupActive;
import com.bwie.service.TbGroupActiveService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 牛毅
 * @version 1.0
 * @date 2025/7/26
 * @description TODO
 */
@RestController
@RequestMapping("/group/groupActive")
public class GroupActiveController {
    @Autowired
    TbGroupActiveService tbGroupActiveService;

    /**
     * @description: 获取拼团活动分页列表
     * @param: pageInfoVo
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/26 11:45
     */
    @PostMapping("/getGroupActiveList")
    public R getGroupActiveList(@RequestBody PageInfoVo pageInfoVo){
        return tbGroupActiveService.getGroupActiveList(pageInfoVo);
    }

    /**
     * @description: 活动添加
     * @param: tbGroupActive
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/26 11:57
     */
    @PostMapping("/addGroupActive")
    public R addGroupActive(@RequestBody @Validated TbGroupActive tbGroupActive, BindingResult result){
        return tbGroupActiveService.addGroupActive(tbGroupActive,result);
    }

    /**
     * @description: 修改活动
     * @param: tbGroupActive
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/26 11:58
     */
    @PostMapping("/updateGroupActive")
    public R updateGroupActive(@RequestBody TbGroupActive tbGroupActive){
        return tbGroupActiveService.updateGroupActive(tbGroupActive);
    }
/** 
 * @description: 删除活动 
 * @param: activeId 
 * @return: com.bwie.utils.R 
 * @author 牛毅
 * @date: 2025/7/28 14:04
 */ 
    @PostMapping("/deleteById/{activeId}")
    public R deleteById(@PathVariable("activeId") Integer activeId){
        return tbGroupActiveService.deleteById(activeId);
    }
}
